<template>
  <div>
    <h1>supplier</h1>
    <div>
      <!-- 列表 -->
      <el-table :data="list" height="380" border style="width: 100%">
        <el-table-column type="index" label="序号" width="60"></el-table-column>
        <el-table-column prop="name" label="供应商名称"></el-table-column>
        <el-table-column
          prop="linkman"
          label="联系人"
          width="120"
        ></el-table-column>
        <el-table-column prop="mobile" label="联系电话"></el-table-column>
        <el-table-column prop="remark" label="备注"></el-table-column>
        <el-table-column label="操作" width="150">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.row.id)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import supplierApi from "@/api/supplier";
export default {
  data() {
    return {
      list: []
    };
  },
  //钩子函数获取数据
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      supplierApi.getList().then(response => {
        this.list = response.data.data;
      });
    },
    handleEdit(id) {
      console.log("编辑");
    },
    handleDele(id) {
      console.log("删除");
    }
  }
};
</script>
